/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.wx.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.wx.entity.WxUserDisValue;
import com.jeesite.modules.wx.service.WxUserDisValueService;

/**
 * wx_user_dis_valueController
 * @author wangjianxin
 * @version 2018-10-02
 */
@Controller
@RequestMapping(value = "${adminPath}/wx/wxUserDisValue")
public class WxUserDisValueController extends BaseController {

	@Autowired
	private WxUserDisValueService wxUserDisValueService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public WxUserDisValue get(String id, boolean isNewRecord) {
		return wxUserDisValueService.get(id, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("wx:wxUserDisValue:view")
	@RequestMapping(value = {"list", ""})
	public String list(WxUserDisValue wxUserDisValue, Model model) {
		model.addAttribute("wxUserDisValue", wxUserDisValue);
		return "modules/wx/wxUserDisValueList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("wx:wxUserDisValue:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<WxUserDisValue> listData(WxUserDisValue wxUserDisValue, HttpServletRequest request, HttpServletResponse response) {
		Page<WxUserDisValue> page = wxUserDisValueService.findPage(new Page<WxUserDisValue>(request, response), wxUserDisValue); 
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("wx:wxUserDisValue:view")
	@RequestMapping(value = "form")
	public String form(WxUserDisValue wxUserDisValue, Model model) {
		model.addAttribute("wxUserDisValue", wxUserDisValue);
		return "modules/wx/wxUserDisValueForm";
	}

	/**
	 * 保存wx_user_dis_value
	 */
	@RequiresPermissions("wx:wxUserDisValue:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated WxUserDisValue wxUserDisValue) {
		wxUserDisValueService.save(wxUserDisValue);
		return renderResult(Global.TRUE, text("保存wx_user_dis_value成功！"));
	}
	
	/**
	 * 删除wx_user_dis_value
	 */
	@RequiresPermissions("wx:wxUserDisValue:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(WxUserDisValue wxUserDisValue) {
		wxUserDisValueService.delete(wxUserDisValue);
		return renderResult(Global.TRUE, text("删除wx_user_dis_value成功！"));
	}
	
}